import java.util.Scanner;

public class Test2 {
    public String name = "asd";
    public String password = "asd";

    public void login()throws UserNameException,PasswordException {
        System.out.println("please input your name: ");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        System.out.println("please input your password: ");
        String password = scanner.nextLine();
        if(!this.name.equals(name)) {
            System.out.println("your name is wrong");
            throw new UserNameException();
        }
        if(!this.password.equals(password)) {
            System.out.println("your password is wrong ");
            throw new PasswordException();
        }
    }

    public static void main(String[] args) {
        Test2 test2 = new Test2();
        try {
            test2.login();
        }catch (UserNameException e){
            e.printStackTrace();
        }catch (PasswordException e) {
            e.printStackTrace();
        }finally {

        }
    }
}
